<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "addTypeForm",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
$url = $control->getAjaxLinkUrl('addType', NULL, array(
    'cooker' => $cooker.'@addType'));
$updateId = $control->getAjaxContainerId();

$descriptionField = 'media_description_add_type';
$model->addField($descriptionField);
?>

<script type="text/javascript">
// this script for collecting the form data and pass to the controller action and doing the on success validations
    function saveType() {

        var formData = new FormData($("#addTypeForm")[0]);
        $.ajax({
            url: '<?php echo $url; ?>',
            type: 'POST',
            data: formData,
            //datatype: 'json',
            // async: false,
            beforeSend: function() {
                $("#ajax-loaderdiv").show();
            },
            success: function(html) {
                // on success do some validation or refresh the content div to display the uploaded images 
                jQuery("#<?php echo $updateId; ?>").html(html);
            },
            complete: function() {
                $("#ajax-loaderdiv").hide();
            },
            error: function(data) {
                alert("There may a error on uploading. Try again later");
            },
            cache: false,
            contentType: false,
            processData: false
        });

        return false;
    }
</script>
<legend>
    <h4>
        <?php
        echo $control->getAjaxLink(array('name' => '功能列表', 'id' => 'showEventList'), array(
            'cooker' => 'BAEventCooker@showEventList'
        ));
        ?>\
        <?php
        echo $control->getAjaxLink(array('name' => '类型列表', 'id' => 'showTypeList'), array(
            'cooker' => 'BAWeJob@showTypeList'
        ));
        ?>
        \设置类型
    </h4>
</legend>
<div class="form">
    <table class="table table-hover">
        <colgroup>
            <col class="span2">
            <col class="span6">
            <col class="span2">
        </colgroup>
        <thead>
            <tr>
                <th><?php echo '属性'; ?></th>
                <th><?php echo '内容'; ?></th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <?php echo '类型名称'; ?>
                </td>
                <td>
                    <?php
                    echo CHtml::activeTextField($model, $name, array('placeholder' => '英文名' . '...', 'required' => true));
                    ?>
                </td>
            </tr>
            <tr>
                <td>
                    <?php echo '类型别名'; ?>
                </td>
                <td>
                    <?php
                    echo CHtml::activeTextField($model, $alias, array('placeholder' => '别名，显示名' . '...', 'required' => true));
                    ?>
                </td>
            </tr> 
            <tr>
                <td>
                    <?php echo '描述'; ?>
                </td>
                <td>
                    <?php
                    echo CHtml::activeTextField($model, $descriptionField, array('placeholder' => '描述' . '...', 'required' => true));
                    ?>
                </td>
            </tr>
        </tbody>
    </table>
    <div>
        <h5 class="text-error"><?php echo CHtml::errorSummary($model); ?></h5>
    </div>
</div>
<?php
$this->endWidget();
//echo CHtml::endForm();
?>
<button class="btn" onclick="javascript:saveType()"><?php echo '保存设置' ?></button>
